/**
 * Copyright 2010 Tristan Slominski
 *
 * Licensed under the MIT License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.opensource.org/licenses/mit-license.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mindash.handlebars.client.places;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.event.shared.GwtEvent;
import com.mindash.handlebars.client.places.handlers.GoToPlaceGenericHandler;

/**
 * An event that notifies of a location change request.
 * 
 * @author Tristan Slominski
 * 
 */
public abstract class GoToPlace<T extends GoToPlaceGenericHandler> extends
    GwtEvent<T> {

  private Map<String, String> params = new HashMap<String, String>();

  @Override
  public void dispatch(T handler) {
    handler.onGoToPlace(this);
  }

  /**
   * @return the parameter map associated with this place instance
   */
  public Map<String, String> getParams() {
    return params;
  }

  /**
   * NOTE: for use by the {@link PlaceService} only.
   * 
   * @return the history token associated with this place
   */
  public abstract String getPlaceHistoryToken();

  /**
   * NOTE: for use by the {@link PlaceService} only.
   * 
   * @param paramMap the parameter map to populate the event with
   */
  public void setParams(Map<String, String> paramMap) {
    this.params = paramMap;
  }
  
}
